<?php
require_once("taskView.php");
require_once(CORE_DIR.'taskModel.php');
require_once(CORE_DIR.'taskpointModel.php');

class deleteAction extends authAction{

	function __construct(){
		$this->view = new taskView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$tModel = new taskModel();	
		$tpModel = new taskpointModel();		
		
		if (isset($get["ids"]) ){
			$ids = $get["ids"];
			
			$idsArray = explode("|", $ids);
			$status = 0;
			
			for ($i = 0; $i < count($idsArray); $i++)
			{
				$id = $idsArray[$i];
				
				if ($tModel->deleteTask($id)){
					$tpModel->deleteTaskPoint($id);
					$status = 1;
				}
			}
			
			$this->view->setProperty("status", $status);
			$this->view->setProperty("id", $ids);
			$this->view->showDeleteTask();
		}
		else{
			$this->view->showBadCmd();
		}	
			
	}
}
?>